Skip to content

feat(miner): add config-gated chat action-dispatch scaffolding - #6542

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6519
Jul 16, 2026
Merged

feat(miner): add config-gated chat action-dispatch scaffolding#6542
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6519

Conversation

@nghetienhiep

Copy link
Copy Markdown
Contributor

Summary

  • Adds the shared, disabled-by-default chat action-dispatch scaffolding required by Chat action-dispatch: shared config-flag-gated dispatch layer (chokepoint-routed) #6519, ahead of the three action-family child issues (Chat action-dispatch: portfolio queue release/requeue #6520 portfolio release/requeue, Chat action-dispatch: governor pause/resume #6521 governor pause/resume, Chat action-dispatch: discover/attempt (new HTTP routes mirroring vite-governor-api.ts) #6522 discover/attempt).
  • packages/loopover-miner/lib/chat-action-dispatch.js — the single dispatch entry point. Checks the LOOPOVER_MINER_CHAT_ACTIONS flag first (fail closed: enabled only for the exact enable value; unset/empty/true/1/ENABLED all read as off), rejects unknown actions, and runs the action's registered params-validator before invoking its handler. It adds no second safety check — the fail-closed enforcement stays in packages/loopover-engine/src/governor/chokepoint.ts, reached through packages/loopover-miner/lib/governor-chokepoint.js.
  • packages/loopover-miner/lib/chat-action-registry.js — the allowlist registry plus a governorGatedHandler() factory. Registration structurally rejects any handler not produced by that factory (a private, non-forgeable brand), so a chat action can never register a handler that bypasses the Governor chokepoint. Ships with zero actions registered.
  • No concrete action family is registered, no HTTP route or vite-*-api.ts is added, and the chokepoint files (chokepoint.ts, governor-chokepoint.js, pretooluse-hook.js) are only called — never modified. apps/loopover-miner-ui/** is untouched.
  • The two *.d.ts companions follow the existing directory convention (every sibling lib/*.js — including local-store.js, governor-chokepoint.js, portfolio-queue.js — ships one; root tsc --noEmit requires them).

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
  • npm run test:coverage — new tests pass; the two new files sit outside src/** so they are not codecov/patch-gated, but every branch is covered by hand: 100% statements / branches / functions / lines on both files (measured unsharded over the two new suites).
  • npm run test:miner-pack — package file allowlist accepts the four new lib/ files.
  • npm run miner:env-reference:check — no drift (the flag is read via a computed member access, not a tracked env.NAME reference).
  • npm audit --audit-level=moderate — 0 vulnerabilities.
  • New behavior has unit tests for every branch: flag-off short-circuit (registry never consulted), unknown-action rejection, params-validator pass/fail/throw, wrapped-accepted vs unwrapped-rejected registration, the real evaluateGovernorChokepointGate default path, and an empty-registry regression guard.

If any required check was skipped, explain why:

  • UI checks (ui:lint/ui:typecheck/ui:build), test:mcp-pack, test:workers, and ui:openapi:check are not affected — this change adds two plain library modules under packages/loopover-miner/lib/ with no UI, MCP, worker, or OpenAPI surface.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, PATs, private keys, trust scores, private rankings, or maintainer evidence are exposed.
  • Public text stays sanitized and implies no compensation guarantees.
  • The dispatch layer introduces no new privilege: it is off by default and empty, and the registration contract forces every future handler through the existing Governor chokepoint rather than adding a competing check. Negative paths (disabled, unknown action, invalid params, unwrapped handler, denied gate) are all tested.
  • No API/OpenAPI/MCP behavior changes.

UI Evidence

Not applicable — no UI, frontend, docs, or extension changes. This is a backend-only library module under packages/loopover-miner/lib/.

Notes

  • This is scaffolding only. The three child issues each register a handler into this registry; because the registration contract blocks an unwrapped handler at registration time, it is structurally impossible for any of them to bypass the chokepoint/PreToolUse path.

Closes #6519

@nghetienhiep
nghetienhiep requested a review from JSONbored as a code owner July 16, 2026 12:34
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.82%. Comparing base (6c1a081) to head (b6bb59f).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6542      +/-   ##
==========================================
+ Coverage   95.81%   95.82%   +0.01%     
==========================================
  Files         589      592       +3     
  Lines       47049    47169     +120     
  Branches    14962    14989      +27     
==========================================
+ Hits        45079    45199     +120     
  Misses       1176     1176              
  Partials      794      794              
Flag Coverage Δ
shard-1 43.90% <0.00%> (-0.06%) ⬇️
shard-2 36.95% <0.00%> (-0.22%) ⬇️
shard-3 32.34% <0.00%> (-0.08%) ⬇️
shard-4 34.65% <81.81%> (-0.05%) ⬇️
shard-5 31.54% <0.00%> (+0.18%) ⬆️
shard-6 45.81% <63.63%> (+0.05%) ⬆️

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

Files with missing lines Coverage Δ
...ackages/loopover-miner/lib/chat-action-dispatch.js 100.00% <100.00%> (ø)
...ackages/loopover-miner/lib/chat-action-registry.js 100.00% <100.00%> (ø)

@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

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-16 13:08:03 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds config-gated scaffolding for a chat action-dispatch system: a flag-checked dispatch entry point (fail-closed unless LOOPOVER_MINER_CHAT_ACTIONS=enabled exactly) and a registry that structurally rejects any handler not produced by governorGatedHandler(), so registered actions can't bypass the Governor chokepoint. The implementation matches its stated scope precisely — zero actions registered, no route/UI changes, existing chokepoint files only called not modified — and the safety contract (private Symbol brand preventing handler forgery) is sound and well-tested, including the real evaluateGovernorChokepointGate integration test. This is inert scaffolding with no reachable production impact until a child issue registers a handler and an operator flips the flag.

Nits — 5 non-blocking
  • The external brief's 'magic numbers' flags on chat-action-dispatch.js:40/42 are false positives — those are step-numbering comments (1./2./3./4.), not literals in code.
  • packages/loopover-miner/lib/chat-action-dispatch.js: consider a small JSDoc note on `readAction` clarifying it intentionally treats non-string actions as null rather than throwing, for readers unfamiliar with the fail-closed convention.
  • The description doesn't explicitly state which issue this PR closes at the top (only 'required by Chat action-dispatch: shared config-flag-gated dispatch layer (chokepoint-routed) #6519' and the checklist item) — worth confirming the linked-issue checkbox references Chat action-dispatch: shared config-flag-gated dispatch layer (chokepoint-routed) #6519 directly for the deterministic gate.
  • packages/loopover-miner/lib/chat-action-registry.js:56-72: the register() function nesting is a touch deep (4 sequential guards) — could extract validation into a small `assertValidDefinition(name, definition)` helper for readability, though this is purely stylistic.
  • Consider adding a one-line note in chat-action-dispatch.js's header pointing directly to the specific test file names (miner-chat-action-dispatch.test.ts / miner-chat-action-registry.test.ts) so future child-issue authors know where the contract tests live.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6519
Related work ⚠️ 3 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: 143 registered-repo PR(s), 82 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nghetienhiep; Gittensor profile; 143 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Review context
  • Author: nghetienhiep
  • 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: 143 PR(s), 0 issue(s).
  • Related work: Titles/paths share 8 meaningful terms. (issue #6522, issue #6521)
  • Related work: Titles/paths share 7 meaningful terms. (issue #6520, issue #6522)
  • Related work: Titles/paths share 7 meaningful terms. (issue #6520, issue #6521)
  • Additional title-only matches omitted; title-only overlap does not block.
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 &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; 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

Adds the shared, disabled-by-default dispatch layer that any chat-issued
miner action must route through, ahead of the three action-family child
issues (portfolio release/requeue, governor pause/resume, discover/attempt).

Two new modules under packages/loopover-miner/lib/:

- chat-action-dispatch.js: the single dispatch entry point. Checks the
  LOOPOVER_MINER_CHAT_ACTIONS flag first (fail closed: on only for the exact
  enable value), rejects unknown actions, and runs the registered
  params-validator before invoking a handler. It adds no second safety check
  of its own -- the fail-closed enforcement stays in the engine chokepoint
  reached via governor-chokepoint.js.

- chat-action-registry.js: the allowlist registry plus a governorGatedHandler()
  factory. Registration structurally rejects any handler not produced by that
  factory, so a chat action can never bypass the Governor chokepoint. Ships with
  zero actions registered.

Both files are outside src/**, so they are not Codecov patch-gated; every
branch is still covered by hand (flag-off short-circuit, unknown-action,
params-validator pass/fail/throw, wrapped-accepted vs unwrapped-rejected, and
an empty-registry regression guard).

Closes JSONbored#6519

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit c9984c1 into JSONbored:main Jul 16, 2026
16 checks passed
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