Skip to content

feat(miner): wire AMS's dead orb-export.js telemetry stub to a real central ingest endpoint - #5697

Merged
JSONbored merged 1 commit into
mainfrom
ams-telemetry-ingest
Jul 14, 2026
Merged

feat(miner): wire AMS's dead orb-export.js telemetry stub to a real central ingest endpoint#5697
JSONbored merged 1 commit into
mainfrom
ams-telemetry-ingest

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • orb-export.js already built a correctly-shaped, HMAC-anonymized batch of PR-outcome telemetry -- but per its own comments (never contradicted until now) it never performed the network send. AMS had zero central visibility into miner-side usage/outcome trends, unlike Orb's own self-host collector.
  • New POST /v1/ams/ingest route + ams_signals/ams_instances tables, mirroring Orb's collector pattern (registration-gate, best-effort upsert on write failure, optional AMS_INGEST_TOKEN bearer gate) -- kept as separate tables from orb_signals/orb_instances rather than a shared discriminator column, since AMS has no gate_verdict/reversal_flag concept and forcing both products into one row shape would mean a pile of always-null Orb-only columns on every AMS row.
  • orb-export.js: real fetch POST, cursor-based incremental resend avoidance (filterBatchSinceCursor/latestClosedAt), a new --send CLI flag (--enable alone still only builds+prints locally -- zero network I/O, so a contributor can inspect exactly what would be sent first), and its own inline HMAC/secret-generation logic replaced with the shared @loopover/engine primitive from Extract shared telemetry-anonymization primitive into @loopover/engine #5680 instead of a second implementation.
  • Ships default OFF -- nothing sends unless a contributor explicitly runs --enable --send. This is a real product/privacy default affecting every existing self-hosted AMS install, not something to silently flip on to match Orb's own opt-out posture.

Test plan

  • npm run build --workspace @loopover/engine clean
  • npx tsc --noEmit --incremental false clean
  • npm run db:migrations:check -- contiguous 0001..0149, no collisions
  • npm run db:schema-drift:check -- ams_signals/ams_instances allowlisted as raw-SQL-only, matches migrations
  • npm run miner:env-reference:check -- new GITTENSORY_MINER_AMS_COLLECTOR_URL/_TOKEN documented
  • npm run test:coverage (unsharded): 829/829 test files, 16065/16065 tests pass
  • Every changed line in src/ams/ingest.ts and the new/modified runOrbExportCli code paths at 100% line/branch/function coverage per coverage/lcov.info, including the DI-fallback branches (real default store/ledger/sender) via an isolated-tmp-DB test mirroring this session's established pattern

Closes #5681

…entral ingest endpoint

orb-export.js already built a correctly-shaped, HMAC-anonymized batch of
PR-outcome telemetry, but per its own comments never performed the network
send -- AMS had zero visibility into miner-side usage/outcome trends.

- New /v1/ams/ingest route + ams_signals/ams_instances tables, mirroring
  Orb's own self-host collector pattern (registration-gate, best-effort
  upsert), with an optional AMS_INGEST_TOKEN bearer gate.
- orb-export.js: real fetch POST + cursor-based incremental resend
  avoidance (filterBatchSinceCursor/latestClosedAt), a new --send CLI flag
  (--enable alone still only builds+prints locally, no network I/O), and
  its own inline HMAC/secret-generation duplicated onto the shared #5680
  engine primitive instead of a second implementation.
- Ships default OFF (opt-in via --send, same as the existing --enable
  gate) -- this is a real privacy/product default, not decided here.

Closes #5681
@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 14, 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
loopover-ui 6871b07 Commit Preview URL

Branch Preview URL
Jul 14 2026, 04:52 AM

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.04%. Comparing base (21d13b2) to head (6871b07).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5697      +/-   ##
==========================================
+ Coverage   95.02%   95.04%   +0.02%     
==========================================
  Files         577      578       +1     
  Lines       45978    46060      +82     
  Branches    14724    14738      +14     
==========================================
+ Hits        43689    43777      +88     
+ Misses       1530     1524       -6     
  Partials      759      759              
Flag Coverage Δ
shard-1 43.99% <6.66%> (-0.07%) ⬇️
shard-2 35.73% <6.66%> (-0.06%) ⬇️
shard-3 32.42% <31.11%> (-0.01%) ⬇️
shard-4 33.08% <43.33%> (+0.02%) ⬆️
shard-5 31.72% <6.66%> (-0.05%) ⬇️
shard-6 44.47% <62.22%> (+0.05%) ⬆️

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

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/cli.js 100.00% <ø> (ø)
packages/gittensory-miner/lib/orb-export.js 98.47% <100.00%> (+7.56%) ⬆️
src/ams/ingest.ts 100.00% <100.00%> (ø)
src/api/routes.ts 94.35% <100.00%> (+0.02%) ⬆️
🚀 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 added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 14, 2026
@loopover-orb

loopover-orb Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-14 04:56:22 UTC

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

⏸️ Suggested Action - Manual Review

  • AI review could not be completed: The dual-model AI review did not return a usable verdict for this change.

Review summary
This PR wires the previously-inert orb-export.js telemetry stub to a real network send, adds a mirrored AMS ingest route/tables (`ams_signals`/`ams_instances`), and reuses the shared `@​loopover/engine` HMAC primitive instead of a second local implementation. The wiring is consistent end-to-end: `--enable --send` is gated behind an explicit new flag (default OFF), cursor advance only happens after `sendResult.sent > 0` and inside the try so `finally` can't close the store early, and the ingest route reuses the existing Orb byte-ceiling/bearer-token pattern with a separate `AMS_INGEST_TOKEN`. Migrations are D1-safe (no TEMP/PRAGMA/ATTACH), schema-drift-allowlisted, and the test suite exercises both the real DI-default path (`fetch` actually called) and the failure/no-op branches (empty batch, non-2xx, network error, cursor null-guard).

Nits — 7 non-blocking
  • packages/gittensory-miner/lib/orb-export.js:144 — the `16` in `amsInstanceId`'s `.slice(0, 16)` and similar truncation lengths elsewhere (24-hex in the old code) are unexplained magic numbers; a named constant would make the hash-length contract self-documenting.
  • src/ams/ingest.ts:71 — the for-loop's nested if/try pushes control-flow depth to 5; consider extracting the per-event validation into a small helper for readability (not a correctness issue).
  • packages/gittensory-miner/lib/orb-export.js:166 — `DEFAULT_AMS_COLLECTOR_URL` hardcodes `api.loopover.ai`, but this exactly mirrors the existing `ORB_COLLECTOR_URL` default pattern in src/selfhost/orb-collector.ts, so it's consistent with house convention rather than a new smell.
  • test/integration/ams-ingest.test.ts's INSERT OR REPLACE path relies on `result.meta.changes > 0` to count acceptance — worth double-checking this stays accurate under D1's real REPLACE semantics (delete+insert) vs the TestD1Database shim, since a mismatch there would silently under/over-count `accepted` without failing any test.
  • Consider whether `MAX_BATCH = 500` truncation (src/ams/ingest.ts) should surface a `skipped` count for `events.length > 500` in the response, mirroring the `skipped` field orb-export.js's CLI already reports on the sender side, so an operator can tell a batch was silently capped.
  • 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.
  • AI review could not be completed — The gate is held for a human reviewer rather than passed automatically; it re-evaluates on the next update.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5681
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: 45 registered-repo PR(s), 37 merged, 320 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 45 PR(s), 320 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: significant — This closes a real dead-code gap (a telemetry builder that never sent anything) with a fully wired, tested, opt-in, default-off network path plus its own migrated backing store, directly matching the PR's stated intent and the referenced #5681 issue.
Linked issue satisfaction

Addressed
The PR wires orb-export.js's fetch POST (default OFF, opt-in --send flag), adds a real central ingest route (src/ams/ingest.ts + /v1/ams/ingest), contiguous migrations for ams_signals/ams_instances, updates docs/observability.md, and includes extensive unit/integration tests covering success, network failure fail-open, and opt-out — all deliverables appear met, with a reasoned deviation (separate

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: Python, TypeScript, Ruby, Go, JavaScript, MDX, Shell, Solidity
  • Official Gittensor activity: 45 PR(s), 320 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 14, 2026
@JSONbored
JSONbored merged commit 4ebce08 into main Jul 14, 2026
20 checks passed
@JSONbored
JSONbored deleted the ams-telemetry-ingest branch July 14, 2026 05:21
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

None yet

Development

Successfully merging this pull request may close these issues.

Wire AMS's dead orb-export.js telemetry stub to a real central ingest endpoint

1 participant