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
- Add a script (e.g.
packages/gittensory-miner/scripts/generate-env-reference.js or equivalent) mirroring selfhost-env-reference.ts's scanning approach.
- Scan
packages/gittensory-miner/** source for GITTENSORY_MINER_*/MINER_* env reads (process.env.X and equivalent access patterns used in this codebase).
- 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.
- Wire an
npm run miner:env-reference script into package.json that regenerates the doc in place.
- 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.
- 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.
- Commit the initial generated
env-reference.md in this same PR.
- Add a short note in
packages/gittensory-miner/README.md pointing to the doc and the regeneration command.
Deliverables / Acceptance Criteria
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
Context
ORB already has
apps/gittensory-ui/src/lib/selfhost-env-reference.tsplusnpm run selfhost:env-reference, a script that scanssrc/selfhost/**for env reads and generates an audited markdown reference, wired into CI to fail on drift.packages/gittensory-miner/**has no equivalent: itsGITTENSORY_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.examplestarter-file issue and the_FILEsecrets-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-runnpm run miner:env-referenceas part of their own commits.Requirements
packages/gittensory-miner/scripts/generate-env-reference.jsor equivalent) mirroringselfhost-env-reference.ts's scanning approach.packages/gittensory-miner/**source forGITTENSORY_MINER_*/MINER_*env reads (process.env.Xand equivalent access patterns used in this codebase).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.npm run miner:env-referencescript intopackage.jsonthat regenerates the doc in place.npm run test:cior 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.env-reference.mdin this same PR.packages/gittensory-miner/README.mdpointing to the doc and the regeneration command.Deliverables / Acceptance Criteria
packages/gittensory-miner/**npm run miner:env-referencewired intopackage.jsonTest 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/**, andapps/gittensory-miner-extension/**currently sit entirely outside vitest'scoverage.includeglob, socodecov/patchcannot measure changes there yet — closing that gap is exactly what #4864 and #4865 (in this same milestone) do. Any part of this change underpackages/gittensory-engine/src/**or the repo's ownsrc/**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 mirroredpackages/gittensory-miner/**— the source tree being scanned