Skip to content

Add a generated, CI-drift-checked env-var reference for gittensory-miner (npm run miner:env-reference) #5179

Description

@JSONbored

Context

ORB already has apps/gittensory-ui/src/lib/selfhost-env-reference.ts plus npm run selfhost:env-reference, a script that scans src/selfhost/** for env reads and generates an audited markdown reference, wired into CI to fail on drift. packages/gittensory-miner/** has no equivalent: its GITTENSORY_MINER_*/MINER_* env vars are only documented by hand (piecemeal across README.md/DEPLOYMENT.md), so a renamed or removed env var can go undetected until an operator hits it in production.

Dependencies

None — independently shippable. It complements, but does not require, the .gittensory-miner.env.example starter-file issue and the _FILE secrets-indirection issue in this same batch — if either of those lands first, this PR's generator should simply pick up their new var names when it scans the tree; if this PR lands first, those issues should re-run npm run miner:env-reference as part of their own commits.

Requirements

  1. Add a script (e.g. packages/gittensory-miner/scripts/generate-env-reference.js or equivalent) mirroring selfhost-env-reference.ts's scanning approach.
  2. Scan packages/gittensory-miner/** source for GITTENSORY_MINER_*/MINER_* env reads (process.env.X and equivalent access patterns used in this codebase).
  3. Generate an audited markdown reference doc (e.g. packages/gittensory-miner/docs/env-reference.md) listing, for each var: its name, the source file(s) that read it, and its default value if one exists in code.
  4. Wire an npm run miner:env-reference script into package.json that regenerates the doc in place.
  5. Add a CI drift check (as part of npm run test:ci or a dedicated step referenced from the CI workflow) that regenerates the doc into a temp location and diffs it against the committed file, failing the build on any difference.
  6. Ensure generator output is deterministic (stable ordering, no timestamps) so re-running it twice on an unchanged tree produces byte-identical output — nondeterministic ordering would cause false drift failures.
  7. Commit the initial generated env-reference.md in this same PR.
  8. Add a short note in packages/gittensory-miner/README.md pointing to the doc and the regeneration command.

Deliverables / Acceptance Criteria

  • Generator script added and produces a markdown reference from a live scan of packages/gittensory-miner/**
  • npm run miner:env-reference wired into package.json
  • CI drift check fails the build when the committed doc is stale relative to the source scan
  • Generator output is deterministic across repeated runs on the same tree
  • Initial generated doc committed
  • README cross-reference added

Test Coverage Requirements

This PR must ship with full test coverage for every changed line and branch — the repo's Codecov patch gate requires 99%+ coverage and the house standard is to aim for 100%, including both sides of every conditional/nullish-coalescing branch introduced. Add: (1) unit tests covering the scanner's success and failure paths (a var present with a default, a var present with no default, a file with zero matching vars, a malformed/unreadable source file), (2) an invariant test asserting the generator's output is byte-for-byte deterministic across two runs on an unchanged tree (no ordering or timestamp drift causing false CI failures), and (3) a regression test reproducing the actual drift scenario this issue exists to catch — add a new env var to a fixture file, assert the CI check fails until the doc is regenerated, then passes after.

Codecov visibility note: packages/gittensory-miner/**, apps/gittensory-miner-ui/**, and apps/gittensory-miner-extension/** currently sit entirely outside vitest's coverage.include glob, so codecov/patch cannot measure changes there yet — closing that gap is exactly what #4864 and #4865 (in this same milestone) do. Any part of this change under packages/gittensory-engine/src/** or the repo's own src/** remains fully Codecov-instrumented as usual. Either way, this does not lower the bar: treat the 100%-including-invariants-and-regression target above as the enforced house standard regardless of what Codecov can currently see, and it becomes gate-enforced for real once #4864/#4865 ship.

Expected Outcome

Any contributor or operator can run one command to get an always-accurate list of every env var the miner reads, and CI will catch it automatically if that list ever goes stale.

Links & Resources

  • apps/gittensory-ui/src/lib/selfhost-env-reference.ts — the pattern being mirrored
  • packages/gittensory-miner/** — the source tree being scanned
  • README.md / DEPLOYMENT.md — where the doc gets cross-referenced
  • Theme: Self-host packaging & docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions