Skip to content

feat(miner-plan): add analyze and prepare plan-DAG templates to the shared engine#2628

Closed
GildardoDev wants to merge 1 commit into
JSONbored:mainfrom
GildardoDev:feat/plan-templates
Closed

feat(miner-plan): add analyze and prepare plan-DAG templates to the shared engine#2628
GildardoDev wants to merge 1 commit into
JSONbored:mainfrom
GildardoDev:feat/plan-templates

Conversation

@GildardoDev

Copy link
Copy Markdown
Contributor

Summary

Adds a small library of reusable plan TEMPLATES to the shared engine as packages/gittensory-engine/src/plan-templates.ts, so a miner does not have to invent its step graph from scratch for each lifecycle stage. Each template is a pure, deterministic builder that returns raw steps in exactly the shape gittensory_build_plan accepts (rawPlanStepSchema in src/mcp/server.ts), so build_plan can normalize them into a validated DAG. Templates only describe steps and their ordering; they never actuate anything.

Closes #2317

Deliverables

  • analyzePlanTemplate(context?) and preparePlanTemplate(context?) returning RawPlanStep[] in the { id, title, actionClass?, dependsOn?, maxAttempts? } shape gittensory_build_plan expects.
    • analyze: feasibility-check and rag-retrieval run independently, then prompt-packet depends on both.
    • prepare: a strict chain of branch-create then coding-agent (a placeholder step, no actuation) then local-test.
  • PLAN_TEMPLATE_BUILDERS (a stage to builder registry) and buildPlanTemplate(stage, context?) so callers can enumerate or dispatch by stage.
  • The optional context.subject is woven into every step title as a single clean line, whitespace-collapsed and length-bounded so a long subject can never push a title past the schema's 300-character limit.

Notes

  • The RawPlanStep type mirrors rawPlanStepSchema so the engine package stays standalone and imports no app code. The unit tests import the ACTUAL rawPlanStepSchema (now exported from src/mcp/server.ts) and assert every template round-trips through it, so the templates can never drift from what gittensory_build_plan accepts.
  • The only change outside the engine package is adding export to the existing rawPlanStepSchema so the drift-guard tests can reference the real schema.

Validation

  • Unit tests cover: a builder exists for every stage, every template round-trips through the real rawPlanStepSchema, ids are unique with only in-plan acyclic dependencies, output is deterministic, the subject is woven as one clean line (and omitted when absent), an oversized subject stays within the 300-char title limit, and the analyze ordering (prompt-packet depends on both feasibility and retrieval).
  • npm run build --workspace @jsonbored/gittensory-engine succeeds; npm run typecheck is clean; the new tests pass under Vitest.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.05%. Comparing base (7d1014e) to head (8bc9142).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2628   +/-   ##
=======================================
  Coverage   96.05%   96.05%           
=======================================
  Files         234      235    +1     
  Lines       26259    26273   +14     
  Branches     9527     9529    +2     
=======================================
+ Hits        25223    25237   +14     
  Misses        425      425           
  Partials      611      611           
Files with missing lines Coverage Δ
packages/gittensory-engine/src/plan-templates.ts 100.00% <100.00%> (ø)
src/mcp/server.ts 95.80% <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 commented Jul 2, 2026

Copy link
Copy Markdown

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-03 02:40:31 UTC

4 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · dirty

⏸️ Suggested Action - Manual Review

Review summary
The change adds a small, pure plan-template library for the analyze and prepare stages, exports it from the engine package, and adds drift-guard tests against the real MCP raw-step schema. The visible templates satisfy the requested ordering, produce schema-valid raw steps, and the only server change is exporting the existing schema for tests. I do not see a reachable correctness break in the diff.

Nits — 4 non-blocking
  • nit: packages/gittensory-engine/src/plan-templates.ts:36 truncates subjects with a raw `.slice`, so a non-BMP character at the boundary can be split; use `Array.from(...).slice(...)` if clean human-facing titles matter here.
  • nit: test/unit/plan-templates.test.ts:18 derives `STAGES` from `PLAN_TEMPLATE_BUILDERS`, so the stage-enumeration test mostly restates the implementation; a separately declared expected stage list would make future omissions easier to catch.
  • packages/gittensory-engine/src/plan-templates.ts:36 could truncate by Unicode code point before composing titles to avoid malformed display text at the boundary.
  • test/unit/plan-templates.test.ts:18 should use a literal expected stage list, then assert both the registry keys and dispatcher output against it so the test is less coupled to the implementation.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2317
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 (size label size:M; 1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 246 registered-repo PR(s), 175 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor GildardoDev; Gittensor profile; 246 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: GildardoDev
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 246 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
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

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Merge conflicts, closing.

This branch has conflicts that must be resolved
Use the [web editor](https://github.com/JSONbored/gittensory/pull/2628/conflicts) or the command line to resolve conflicts before continuing.

packages/gittensory-engine/src/index.ts

@GildardoDev

Copy link
Copy Markdown
Contributor Author

Merge conflicts, closing.

This branch has conflicts that must be resolved
Use the [web editor](https://github.com/JSONbored/gittensory/pull/2628/conflicts) or the command line to resolve conflicts before continuing.

packages/gittensory-engine/src/index.ts

sorry, but could you plz reopen this PR? so i will fix merge conflict problem

JSONbored added a commit that referenced this pull request Jul 8, 2026
…d duplicate parser (#4318)

Two independently-filed issues (#2652's follow-up to #2293, and #2301)
both specified a MinerGoalSpec parser. Two implementations landed
around the same time: miner-goal-spec.ts became canonical (re-exported
from the package barrel, the only one packages/gittensory-miner's real
caller actually imports), while miner-goal-spec-parse.ts's own PR
explicitly avoided the barrel "while #2628 is open" as a temporary
conflict-avoidance measure that was never reconciled -- it sat
published as its own npm subpath export with zero real callers
anywhere in the repo.

More importantly: the canonical file has the exact resource-exhaustion
bug that #2896 patched in its orphaned sibling and nowhere else.
normalizeStringList's cap check only fired after a candidate was
accepted, so an array of entries that always take the `continue` path
(non-string, duplicate, or empty-after-trim) never hit the cap and got
scanned in full -- a hostile `.gittensory-miner.yml` with thousands of
duplicate/invalid list entries could force unbounded CPU/memory work
and unbounded warning growth on every repo a miner considers, since
this parser runs on untrusted per-repo config.

- Bound normalizeStringList's iteration to the raw array index, before
  any per-entry work, mirroring #2896's fix -- but WITHOUT that fix's
  own latent bug: a trailing `result.length >= cap` break (kept for
  "defense in depth") fires silently, with no warning, whenever the
  input has exactly cap+1 unique valid entries. A pre-existing test
  ("caps oversized string lists and ignores extra entries") caught
  this regression during review. The index-based check alone is both
  necessary and sufficient to bound work; the trailing check is
  removed rather than mirrored.
- Delete the orphaned miner-goal-spec-parse.ts and its dedicated test
  (confirmed zero real callers, in-repo or via its published subpath).
- Remove the ./miner-goal-spec-parse subpath from package.json's
  exports map. BREAKING CHANGE: @jsonbored/gittensory-engine's
  published subpath export is removed. The package is one week old
  with a single in-repo consumer that never used this subpath; no
  known external impact.
- Add hostile-input regression tests (all-non-string, all-duplicate,
  all-empty, all-overlong) to both the package-level and root-level
  test suites for the canonical parser, mirroring the coverage #2896
  added for its now-deleted sibling.
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.

Development

Successfully merging this pull request may close these issues.

feat(miner-plan): discover→manage plan-template library extending the MCP plan-DAG shape

2 participants