Skip to content

feat(miner): add chat action-dispatch scaffolding (#6519) - #6544

Closed
glorydavid03023 wants to merge 1 commit into
JSONbored:mainfrom
glorydavid03023:feat/miner-chat-action-dispatch
Closed

feat(miner): add chat action-dispatch scaffolding (#6519)#6544
glorydavid03023 wants to merge 1 commit into
JSONbored:mainfrom
glorydavid03023:feat/miner-chat-action-dispatch

Conversation

@glorydavid03023

Copy link
Copy Markdown
Contributor

Summary

  • Adds the shared, disabled-by-default scaffolding (Chat action-dispatch: shared config-flag-gated dispatch layer (chokepoint-routed) #6519) the three chat action-family child issues (discover/attempt, portfolio release/requeue, governor pause/resume) will register their handlers into. This PR wires no concrete action: the flag defaults OFF and the registry ships empty, so nothing observable changes — no dashboard button, CLI command, or MCP tool behaves differently.
  • packages/loopover-miner/lib/chat-action-registry.js (new): the allowlist registry + createChokepointRoutedHandler, which routes an action's effect through the existing governor-chokepoint.js evaluateGovernorChokepointGate wrapper (the fail-closed precedence ladder) and brands the result. registerChatAction accepts only branded handlers — a raw, unwrapped function is rejected at registration time, so a chat-triggered write cannot structurally bypass the Governor chokepoint. Every action must also supply its own params-validator.
  • packages/loopover-miner/lib/chat-action-dispatch.js (new): dispatchChatAction, the single entry point every chat-issued action must go through. Fail-closed order — the MINER_CHAT_ACTIONS flag (explicit enable values only; unset/empty/anything-else = off) is checked first, before the registry is touched or params validated; then unknown-action rejection, then the params-validator (rejecting, never coercing, on failure), then the registered handler.

Closes #6519.

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.
  • I linked a currently open issue this PR resolves (Closes #6519).

Validation

  • git diff --check
  • npm run typecheck (0 errors)
  • npm run test:coverage — the two new files (packages/loopover-miner/lib/chat-action-{dispatch,registry}.js, both inside Codecov's measured paths) are at 100% branch, statement, function, and line coverage: flag-off short-circuit, unknown-action + non-string-action rejection, both params-validator arms (incl. a falsy validator result and a missing errors array), the wrapped-accepted vs raw-rejected handler contract, empty-name/missing-validator/duplicate rejections, and the ships-empty regression.
  • New/changed behavior has tests for new branches and fail-closed paths.

If any required check was skipped, explain why:

  • test:workers, build:mcp, test:mcp-pack, ui:*, actionlint, npm audit were not run locally — this PR adds only two packages/loopover-miner/lib/ modules + their tests; it touches no Cloudflare Worker, MCP package, UI, workflow, or dependency. ui:openapi:check is unaffected (no src/api route/schema change). This Windows dev environment reports CRLF false-positives on the tree-wide prettier/openapi/engine-parity checks (pre-existing on clean main); committed files are LF. CI (Linux) is the authoritative gate.

Safety

  • No secrets, wallets, hotkeys, coldkeys, PATs, private keys, raw trust scores, private rankings, or maintainer evidence are exposed.
  • Public text stays sanitized and low-noise.
  • Auth/CORS/session unchanged — this is an inert library module (flag off, registry empty). Its safety property (a raw handler cannot be registered) is asserted by a negative-path test.
  • No API/OpenAPI/MCP behavior changed. Does not modify chokepoint.ts / governor-chokepoint.js / pretooluse-hook.js — it only calls into them, unchanged; it adds no second, competing safety check.
  • No visible UI (backend-only, per the issue). No HTTP route or vite-*-api.ts is added here.

UI Evidence

Not applicable — backend-only library scaffolding, no UI or rendered surface.

Notes

  • Deliberately ships the registry with zero actions registered; the discover/attempt, portfolio release/requeue, and governor pause/resume child issues each register a handler (which the registration contract forces through the Governor chokepoint). A regression test guards against a future PR accidentally pre-registering an action family in this module.

Add the shared, disabled-by-default scaffolding the three chat action-family
child issues (discover/attempt, portfolio release/requeue, governor
pause/resume) register their handlers into. This issue wires no concrete
action: the flag defaults OFF and the registry ships empty, so nothing
observable changes.

- `packages/loopover-miner/lib/chat-action-registry.js`: the allowlist registry
  plus `createChokepointRoutedHandler`, which routes an action's effect through
  the existing `governor-chokepoint.js` `evaluateGovernorChokepointGate` wrapper
  (the fail-closed precedence ladder) and brands the result. `registerChatAction`
  accepts ONLY branded handlers — a raw, unwrapped function is rejected at
  registration time, so a chat-triggered write cannot structurally bypass the
  Governor chokepoint. Every action must also supply its own params-validator.
- `packages/loopover-miner/lib/chat-action-dispatch.js`: `dispatchChatAction`,
  the single entry point every chat-issued action must go through. Fail-closed
  order — the `MINER_CHAT_ACTIONS` flag (explicit enable values only) is checked
  FIRST, before the registry is touched or params are validated; then an unknown
  action is rejected, the action's params-validator runs (rejecting, never
  coercing, on failure), and only then is the registered handler invoked.

Does not add any HTTP route, `vite-*-api.ts`, or UI, and does not modify
`chokepoint.ts`/`governor-chokepoint.js`/`pretooluse-hook.js` — it only calls
into them, unchanged.

Tests cover both files to 100% branch: flag-off short-circuit, unknown-action
rejection, params-validator pass/fail, the wrapped-accepted vs raw-rejected
handler contract, and a regression test asserting the registry ships empty.
@superagent-security

Copy link
Copy Markdown
Contributor

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

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

loopover-orb Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-16 13:00:17 UTC

6 files · 1 AI reviewer · 1 blocker · CI failing · blocked

🛑 Suggested Action - Reject/Close

Review summary
This adds a disabled-by-default chat action-dispatch scaffold: a registry (chat-action-registry.js) that only accepts handlers produced by createChokepointRoutedHandler (structurally forcing every future chat action through the Governor chokepoint gate), and a single dispatch entry point (chat-action-dispatch.js) that checks the MINER_CHAT_ACTIONS flag first, then unknown-action, then params validation, then invocation. The fail-closed ordering, the non-enumerable Symbol brand preventing raw-handler registration, and the flag regex (explicit enable values only) are all correctly implemented and match the stated intent — nothing is wired to any observable surface yet, matching the 'scaffolding only' claim. Test coverage across both new files is thorough (including both arms of the validator's ok/errors branches and the allow/deny gate paths).

Nits — 5 non-blocking
  • packages/loopover-miner/lib/chat-action-registry.js:76 nests to depth 5 inside registerChatAction (four sequential guard-throws before the Map write) — consider early-returning via a helper or flattening the checks for readability.
  • Neither d.ts nor the JS validates that an action `name` is restricted to a safe charset (e.g. dotted identifiers) before use as a Map key — harmless today since the registry is populated only by trusted in-repo child-issue code, but worth a comment or guard once names could ever originate from configuration.
  • The default `evaluateGate` path (chat-action-registry.js:29) is `/* v8 ignore */`'d and never exercised by this PR's own tests, relying entirely on governor-chokepoint's separate test suite for coverage of the real wiring — reasonable per the comment, but worth double-checking in the child-issue PRs that first exercise it for real.
  • Consider adding one integration-style test in a follow-up child-issue PR that calls createChokepointRoutedHandler with the *real* evaluateGovernorChokepointGate (not the injected fake) end-to-end, to catch any GovernorChokepointInput shape drift the type-only contract wouldn't.
  • In chat-action-dispatch.js, `action` silently coerces a non-string/absent value to `""` before the unknown-action check — fine as implemented and tested, just worth a one-line comment noting this is intentional coercion-to-empty rather than a validation gap.

Why this is blocked

  • Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.

CI checks failing

  • validate
  • validate-tests (6)
  • validate-tests (2)
  • validate-code

Decision drivers

  • ❌ Code review — 1 blocker (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6519
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High 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: 290 registered-repo PR(s), 177 merged, 20 issue(s).
Contributor context ✅ Confirmed Gittensor contributor glorydavid03023; Gittensor profile; 290 PR(s), 20 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The PR adds exactly the two required files under packages/loopover-miner/lib/ implementing a fail-closed config flag checked before registry/validation, an empty allowlist registry that structurally rejects unwrapped handlers via createChokepointRoutedHandler (routing through the existing governor-chokepoint wrapper, unmodified), mandatory per-action params-validators enforced before handler invoc

Review context
  • Author: glorydavid03023
  • 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: 290 PR(s), 20 issue(s).
  • Related work: Titles/paths share 7 meaningful terms. (issue #6520, issue #6519)
  • Related work: Titles/paths share 7 meaningful terms. (issue #6521, issue #6519)
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests (6), validate-tests (2), validate-code); Linked issue overlaps another open PR; duplicate of open PR #6542). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 16, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat action-dispatch: shared config-flag-gated dispatch layer (chokepoint-routed)

1 participant