Skip to content

fix(ci): guard RepoSettingsPreviewSchema against settings-preview drift - #7053

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7011
Jul 17, 2026
Merged

fix(ci): guard RepoSettingsPreviewSchema against settings-preview drift#7053
JSONbored merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7011

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

Summary

  • scripts/check-openapi-settings-parity.mjs's header names both RepositorySettingsSchema and RepoSettingsPreviewSchema as hand-authored Zod schemas needing drift protection, but main() only checked the former. This adds the missing second check for RepoSettingsPreviewSchema.settings.
  • New pure, exported, unit-tested extractRepoSettingsPreviewFieldNames diffs the schema's settings key set against buildRepoSettingsPreview's return shape — its named return type RepoSettingsPreview in src/signals/settings-preview.ts (the source of truth the issue names). It brace-matches the nested settings block so the inline commandAuthorization members don't leak in, and fails CI with the same actionable message as the existing check.
  • Wiring the check up surfaced a real drift it was designed to catch: RepoSettingsPreviewSchema.settings has declared autoProjectMilestoneMatch / autoProjectMilestoneMatchBackend since feat(agent): add Linear backend for project/milestone matching #3290, but buildRepoSettingsPreview never populated them — so the endpoint never returned two fields its own OpenAPI spec documents. They are plain RepositorySettings fields, so I wired them into the builder's return shape to honor the spec. The Zod schema and generated openapi.json are unchanged.
  • The existing RepositorySettingsSchema / RepositorySettings check is untouched.

Closes #7011

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 #7011).

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run ui:openapi:settings-parity — both checks green (RepositorySettings 110 fields, RepoSettingsPreview.settings 37 fields)
  • npm run ui:openapi:check — generated spec unchanged
  • Targeted coverage: the two added executable lines in src/signals/settings-preview.ts are exercised by test/unit/settings-preview.test.ts (no new branches); new script functions have full unit coverage in test/unit/ci-openapi-settings-parity.test.ts
  • npm audit --audit-level=moderate — 0 vulnerabilities
  • New behavior has unit tests (extraction happy-path incl. nested/sibling exclusion, three error paths, real-schema regression guard)

Not run locally (unaffected by this backend-only change; no MCP/UI/worker surface touched): test:workers, build:mcp, test:mcp-pack, ui:lint, ui:typecheck, ui:build.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, PATs, private keys, trust scores, or private evidence are exposed.
  • Public GitHub text stays sanitized and low-noise.
  • API/OpenAPI behavior is updated and tested where needed — the settings-preview endpoint now returns the two fields its spec already documented; the schema itself is unchanged.

Notes

  • No UI/frontend/docs changes, so no UI Evidence is required.

The settings-parity check's own header names both RepositorySettingsSchema
and RepoSettingsPreviewSchema as hand-authored Zod schemas needing drift
protection, but main() only diffed RepositorySettingsSchema against the
RepositorySettings type -- RepoSettingsPreviewSchema had no check at all.

Add a second pure extraction (extractRepoSettingsPreviewFieldNames) + diff
wired into main(), covering RepoSettingsPreviewSchema.settings against
buildRepoSettingsPreview's return shape (the named RepoSettingsPreview type
in src/signals/settings-preview.ts). It brace-matches the nested settings
block so the inline commandAuthorization members don't leak in, and fails
CI with the same actionable message as the existing check.

This surfaced a real drift: the schema has always declared
autoProjectMilestoneMatch/autoProjectMilestoneMatchBackend (since JSONbored#3290)
but the builder never populated them, so the endpoint never returned the
two fields its own OpenAPI spec documents. Wire them into the builder's
return shape (they are plain RepositorySettings fields) so the endpoint
honors the spec and the new parity check passes; the schema and generated
openapi.json are unchanged.

Closes JSONbored#7011
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 17, 2026 19:46
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.74%. Comparing base (bdb11d9) to head (ce8d1b5).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7053      +/-   ##
==========================================
- Coverage   95.98%   93.74%   -2.24%     
==========================================
  Files         609      692      +83     
  Lines       48137    68706   +20569     
  Branches    15132    18760    +3628     
==========================================
+ Hits        46202    64409   +18207     
- Misses       1118     3302    +2184     
- Partials      817      995     +178     
Flag Coverage Δ
shard-1 43.79% <ø> (+0.40%) ⬆️
shard-2 36.85% <ø> (+<0.01%) ⬆️
shard-3 33.13% <ø> (-0.03%) ⬇️
shard-4 34.48% <ø> (+0.08%) ⬆️
shard-5 32.27% <ø> (+0.61%) ⬆️
shard-6 45.75% <ø> (-0.32%) ⬇️

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

Files with missing lines Coverage Δ
src/signals/settings-preview.ts 98.78% <ø> (ø)

... and 84 files with indirect coverage changes

@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 20:09:52 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This closes a real drift-detection gap: the parity script's own header named RepoSettingsPreviewSchema as needing a guard but main() never checked it, and wiring the second check up surfaced an actual bug — buildRepoSettingsPreview was silently dropping autoProjectMilestoneMatch/autoProjectMilestoneMatchBackend that the Zod schema and OpenAPI spec already document. The new extractRepoSettingsPreviewFieldNames correctly brace-matches to avoid leaking the nested commandAuthorization members, and is exercised by both synthetic fixtures and a real-file regression test. This is a well-scoped, narrow fix that traces to its root cause (the builder, not the schema) and is properly tested.

Nits — 3 non-blocking
  • The console.log/console.error calls flagged by the brief are the script's normal reporting/exit-code mechanism (unchanged pattern from the pre-existing RepositorySettings check), not debug leftovers — no action needed.
  • scripts/check-openapi-settings-parity.mjs:41/:60 hardcode indent widths (2 vs 4 spaces) as regex literals; consider a named constant if the type ever gets reformatted to keep both extractors in sync.
  • Consider factoring the repeated 'missingFromSchema/extraInSchema' console-reporting block (lines ~76-90 and ~99-112) into a small shared helper since the two checks now duplicate the same message-shape logic.

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 #7011
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: 0 registered-repo PR(s), 0 merged, 0 issue(s).
Contributor context ℹ️ No public Gittensor match bitfathers94; not a blocker.
Improvement ✅ Minor risk: clean · value: minor
Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Contributor context: Public profile only; not a blocker.
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 17, 2026
@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 17, 2026
@JSONbored
JSONbored merged commit dab4c0e into JSONbored:main Jul 17, 2026
15 checks passed
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. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check-openapi-settings-parity.mjs only checks RepositorySettingsSchema, not RepoSettingsPreviewSchema despite its own header naming both

2 participants