Skip to content

feat: hyperparameter editing UI (auth, edit form, history tab, admin register)#1345

Draft
LandynDev wants to merge 3 commits into
testfrom
feat/hyperparam-api
Draft

feat: hyperparameter editing UI (auth, edit form, history tab, admin register)#1345
LandynDev wants to merge 3 commits into
testfrom
feat/hyperparam-api

Conversation

@LandynDev

Copy link
Copy Markdown
Collaborator

Hyperparameter Editing API — UI (Phase 5)

Greenfield GitHub-auth + self-service repository-hyperparameter editing, part of the cross-repo effort to replace the PR→JSON flow with an authed API (das DB as source of truth).

What's in here

  • Auth foundationsrc/auth/token.ts (localStorage JWT store), AuthContext/useAuth (captures das's #token= post-login fragment, hydrates via GET /auth/me, exposes user/isAuthenticated/isAdmin/loading + login()/logout()), wired in main.tsx.
  • API client — dedicated apiClient axios instance with a Bearer interceptor (kept separate from the github/mirror clients so the JWT never leaks cross-origin); useApiQuery routes through it; new useApiMutation helper with auto query-invalidation.
  • Write hooks (ReposApi.ts) — useUpdateRepositoryConfig, useSetEmissionShare, useRegisterRepository, useDeleteRepository, useRepositoryConfigHistory.
  • Editable hyperparameters form — auth-gated edit mode on RepositoryHyperparametersTab; reuses repoConfig.ts field defs/bounds with client validation mirroring das config-validation.ts; sends a changed-only snake_case patch (no-op saves don't burn the 1/day cooldown; defaults aren't frozen into overrides); nested time_decay sent whole (das merges one level deep); emission_share admin-only.
  • Change-history tabRepositoryConfigHistoryTab (audit trail, before→after diffs, "last edited by").
  • Admin register-repo form — direct POST /repos, self-gated to admins, on the registration page alongside the public request flow.
  • repoConfig.ts — added TOP_LEVEL_FIELD_DEFS + shared validateFieldValue() (also backs the cross-repo bounds contract test in gt-utils).

tsc --noEmit clean.

⚠️ Merge ordering (cross-repo)

This UI depends on the das API (entrius/das-gittensor#82) being deployed and Phase 0 OAuth being configured. Do not merge/ship before das is live, or the edit/login UI has no backend. Related: gittensor-db #50, das #82, gittensor #1511 (draft), gt-utils #4.

🤖 Generated with Claude Code

Phase 5.1 + 5.5 of the hyperparam-API UI (greenfield auth):

- src/auth/token.ts: localStorage-backed JWT store (read by the API client
  interceptor and AuthContext), failure-tolerant.
- src/auth/AuthContext.tsx: AuthProvider + useAuth. Captures the das post-login
  `#token=` redirect fragment, hydrates the user via GET /auth/me, exposes
  user/isAuthenticated/isAdmin/loading + login()/logout(). login() redirects to
  {API}/auth/github; a 401 clears the session.
- ApiUtils: dedicated `apiClient` axios instance with a Bearer request
  interceptor (kept separate from the github/mirror clients so the JWT never
  leaks cross-origin); useApiQuery now routes through it; new useApiMutation
  helper (auto query invalidation on success).
- ReposApi: write hooks (useUpdateRepositoryConfig, useSetEmissionShare,
  useRegisterRepository, useDeleteRepository) + useRepositoryConfigHistory,
  plus RepositoryConfigEdit / RepositoryConfigPatch types.
- main.tsx: wrap the app in AuthProvider.

Editable form / admin register form / history tab (5.2-5.4) build on this next.
tsc --noEmit clean.
Phase 5.2: add an auth-gated edit mode to RepositoryHyperparametersTab.

- RepositoryHyperparametersEditForm: inputs for the eligibility/scoring/time-decay
  knob groups + top-level scalars, reusing repoConfig.ts field defs/bounds with
  client-side validation mirroring das config-validation.ts. Builds a snake_case
  patch of ONLY changed fields (no-op saves don't burn the 1/day cooldown; defaults
  don't get frozen into overrides). Nested time_decay is sent whole when any of its
  knobs change (das merges one level deep). emission_share is admin-only (read-only
  for maintainers); trusted_label_pipeline + scorable branches editable; optional
  note recorded in history. Surfaces the API error (403 cooldown / not-a-maintainer).
- repoConfig.ts: add TOP_LEVEL_FIELD_DEFS (emission_share, issue_discovery_share,
  maintainer_cut, default_label_multiplier, fixed_base_score) and a shared
  validateFieldValue() bounds checker.
- Tab shows an Edit button to authenticated users; the server guard enforces real
  maintainer/admin perms.

tsc --noEmit clean.
Completes Phase 5 of the hyperparam-API UI.

5.4 — RepositoryConfigHistoryTab: new "History" tab in RepositoryDetailsPage
consuming useRepositoryConfigHistory; renders the audit trail newest-first with
actor (maintainer/admin), timestamp, optional note, per-changed-key before->after
diff, repo created/deleted lifecycle markers, and a "last edited by … on …" line.
Tab key appended so existing tab indices / back-nav stay stable.

5.3 — AdminRegisterRepositoryForm: admin-only direct registration (POST /repos),
added to RepositoryRegistrationPage above the public request flow (self-gates on
the admin session, so non-admins still see the existing email/App-install flow).
fullName owner/repo validation + optional initial config reusing
TOP_LEVEL_FIELD_DEFS/validateFieldValue; on success routes to the new repo's
hyperparameters tab.

tsc --noEmit clean.
@anderdc anderdc marked this pull request as draft July 2, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant