Skip to content

refactor(selfhost): dual-read LOOPOVER_-prefixed env vars alongside GITTENSORY_#5561

Merged
JSONbored merged 1 commit into
mainfrom
loopover/env-var-dual-read
Jul 13, 2026
Merged

refactor(selfhost): dual-read LOOPOVER_-prefixed env vars alongside GITTENSORY_#5561
JSONbored merged 1 commit into
mainfrom
loopover/env-var-dual-read

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Introduces LOOPOVER_-prefixed equivalents for the 7 self-host operational env vars actually read outside the GITTENSORY_REVIEW_* feature-flag family: GITTENSORY_API_TOKEN, GITTENSORY_MCP_TOKEN, GITTENSORY_VERSION, GITTENSORY_REPO_CONFIG_DIR, GITTENSORY_ENABLE_PAGERDUTY, GITTENSORY_ENABLE_UNSAFE_CODEX_REVIEWER, and GITTENSORY_DISCORD_WEBHOOK.

A new shared src/utils/env.ts (dualPrefixEnvString/Flag/StrictFlag) is the single source of the precedence rule (LOOPOVER_ wins when both are set, falls back to GITTENSORY_ otherwise) so it can't drift per call site the way this repo's existing per-file nonBlank/envString helpers already have. An untouched .env with only GITTENSORY_* vars keeps working byte-identical.

Regenerated apps/gittensory-ui/src/lib/selfhost-env-reference.ts last, after all variable changes landed, per the issue's own explicit ordering warning. Also fixed the generator itself (scripts/gen-selfhost-env-reference.mjs): its AST scanner only recognized literal env.NAME reads and a small helper allowlist, so swapping a literal read for a dualPrefixEnvString() call made that var invisible to the doc generator entirely — taught it to recognize the three new helpers and expand each into both prefix rows, with test coverage.

Scope note

The issue's text ("roughly twenty... including a whole family of feature-flag variables") also covers the 22-variable GITTENSORY_REVIEW_* family (CONTENT_LANE, CONTINUOUS, GROUNDING, RAG, SAFETY, etc.), which is not included here — filed as a dedicated follow-up (#5555) rather than tripling this PR's size, since the same dualPrefixEnvFlag helper applies directly once that PR lands.

Test plan

  • Full npm run test:ci gate green.
  • New test/unit/utils-env.test.ts covers all 3 helper functions' precedence/blank-handling behavior.
  • Verified the reference-doc generator fix: regenerating without it silently deleted 3 pre-existing rows and added zero new ones — caught and fixed before this landed, with a regression test.
  • npm run selfhost:env-reference:check passes clean against the committed, regenerated file.
  • npm audit --audit-level=moderate — 0 vulnerabilities.

Advances #4774 (see #5555 for the remaining REVIEW_* flag family).

…ITTENSORY_

Introduces LOOPOVER_-prefixed equivalents for the 7 self-host operational
env vars actually read outside the GITTENSORY_REVIEW_* feature-flag family:
GITTENSORY_API_TOKEN, GITTENSORY_MCP_TOKEN, GITTENSORY_VERSION,
GITTENSORY_REPO_CONFIG_DIR, GITTENSORY_ENABLE_PAGERDUTY,
GITTENSORY_ENABLE_UNSAFE_CODEX_REVIEWER, and GITTENSORY_DISCORD_WEBHOOK.

A new shared src/utils/env.ts (dualPrefixEnvString/Flag/StrictFlag) is the
single source of the precedence rule (LOOPOVER_ wins when both are set,
falls back to GITTENSORY_ otherwise) so it can't drift per call site the
way this repo's existing per-file nonBlank/envString helpers already have.
An untouched .env with only GITTENSORY_* vars keeps working byte-identical.

Regenerated apps/gittensory-ui/src/lib/selfhost-env-reference.ts LAST, after
all variable changes landed, per the issue's own explicit ordering warning.
Also fixed the generator itself (scripts/gen-selfhost-env-reference.mjs): its
AST scanner only recognized literal env.NAME reads and a small helper
allowlist, so swapping a literal read for a dualPrefixEnvString() call made
that var invisible to the doc generator entirely -- taught it to recognize
the three new helpers and expand each into both prefix rows.

Scope note: the issue's text ("roughly twenty... including a whole family of
feature-flag variables") also covers the 22-variable GITTENSORY_REVIEW_*
family (CONTENT_LANE, CONTINUOUS, GROUNDING, RAG, SAFETY, etc.), which is
NOT included here -- filed as a dedicated follow-up (#5555) rather than
tripling this PR's size, since the same dualPrefixEnvFlag helper applies
directly once that PR lands.

Advances #4774 (see #5555 for the remaining REVIEW_* flag family).
@JSONbored JSONbored self-assigned this Jul 13, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

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
gittensory-ui 095ba28 Commit Preview URL

Branch Preview URL
Jul 13 2026, 05:19 AM

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (df5336e) to head (095ba28).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5561   +/-   ##
=======================================
  Coverage   94.91%   94.91%           
=======================================
  Files         570      571    +1     
  Lines       45351    45360    +9     
  Branches    14675    14680    +5     
=======================================
+ Hits        43046    43055    +9     
  Misses       1571     1571           
  Partials      734      734           
Flag Coverage Δ
shard-1 44.14% <35.00%> (-0.01%) ⬇️
shard-2 35.71% <50.00%> (+<0.01%) ⬆️
shard-3 31.94% <45.00%> (+<0.01%) ⬆️
shard-4 31.86% <45.00%> (-0.02%) ⬇️
shard-5 32.83% <40.00%> (-0.18%) ⬇️
shard-6 44.33% <50.00%> (+0.17%) ⬆️

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

Files with missing lines Coverage Δ
src/api/routes.ts 94.30% <100.00%> (ø)
src/auth/security.ts 98.85% <100.00%> (+0.01%) ⬆️
src/selfhost/ai.ts 98.15% <100.00%> (ø)
src/selfhost/health.ts 100.00% <100.00%> (ø)
src/selfhost/otel.ts 100.00% <100.00%> (ø)
src/selfhost/preflight.ts 100.00% <100.00%> (ø)
src/selfhost/sentry.ts 99.64% <100.00%> (ø)
src/services/notify-discord.ts 100.00% <100.00%> (ø)
src/services/notify-pagerduty.ts 100.00% <100.00%> (ø)
src/utils/env.ts 100.00% <100.00%> (ø)
🚀 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:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪

🔍 Gittensory is reviewing…

AI analysis is in progress. This comment will update when the review is complete.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing

@JSONbored
JSONbored merged commit f30061c into main Jul 13, 2026
20 checks passed
@JSONbored
JSONbored deleted the loopover/env-var-dual-read branch July 13, 2026 05:24
JSONbored added a commit that referenced this pull request Jul 13, 2026
…side LOOPOVER_ (#5593)

Closes #5555. Follow-up to #4774/#5561, which covered the 7 self-host
operational vars but deliberately left out this larger 22-variable
GITTENSORY_REVIEW_* feature-flag family.

Applies the already-merged dualPrefixEnvFlag/dualPrefixEnvString
helpers (src/utils/env.ts) to all 22 flags, so LOOPOVER_REVIEW_* wins
when both prefixes are set, falling back to the legacy GITTENSORY_
name otherwise. An untouched self-host .env keeps working unchanged.

Two flags needed special handling rather than a mechanical swap:
- REVIEW_REPOS is a raw comma-separated allowlist string, not a
  boolean flag -- uses dualPrefixEnvString, not dualPrefixEnvFlag,
  across its 2 read sites in cutover-gate.ts.
- REVIEW_SELFTUNE has 2 independent read sites (selftune-wire.ts and
  a deliberate duplicate in settings/repository-settings.ts, inlined
  there specifically to avoid an import cycle) -- both converted,
  importing dualPrefixEnvFlag directly from utils/env rather than
  reintroducing the cycle.

CONTENT_LANE's flag.ts previously used a hand-rolled Set-membership
truthy check instead of the shared regex; functionally identical for
the 4 accepted tokens (1/true/yes/on, trimmed, case-insensitive), so
safely replaced with the shared helper.

apps/gittensory-ui/src/lib/selfhost-env-reference.ts is NOT
regenerated here -- its generator's DEFAULT_SOURCE_ROOTS never
included src/review/**, src/queue/**, or src/settings/** (confirmed:
none of these 22 vars, even in their single-prefix form, appear in
that file on main either), so it's out of scope for this doc,
unrelated to this change. Added LOOPOVER_REVIEW_* companion lines to
.env.example / .env.selfhost.example instead, next to each flag's
existing GITTENSORY_REVIEW_* line, matching #5561's documentation
pattern -- this is the real documentation surface for these flags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dual-read the GITTENSORY_REVIEW_* feature-flag family (env var migration follow-up)

1 participant