Skip to content

refactor(admin): move the pure backup model into admin_backup_model.js - #1337

Draft
gcs8 wants to merge 2 commits into
mainfrom
refactor/admin-backup-model
Draft

gcs8 wants to merge 2 commits into
mainfrom
refactor/admin-backup-model

Conversation

@gcs8

@gcs8 gcs8 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

What moved where

The pure part of the backup library's model moves from admin_service/static/admin_backups.js into a new static script, admin_service/static/admin_backup_model.js: scrubText, validId, the provider, location and state labels, isRestorable, canDownload, groupArtifacts, humanKey, describePolicy, humanizePlanReason, normalizePlan, verifiedDetailText, lastRunSummary, lastCheckSummary, cleanupSummary, shortHash, secretStateText, buildPolicyPayload, their private helpers, and the constants they read (ID_PATTERN, CLASSES, PROVIDER_LABELS, STATE_LABELS, SENSITIVE_KEY, the secret labels and the target field sets).

The new file has the same wrapper as the library: a browser script that sets window.AdminBackupModel, and a CommonJS module under Node. admin_backups.js takes the names it uses from it with one destructuring statement. Its exports (createBackupLibrary, model) and its model object keep every key. base.html loads the model script before the library.

The URL builders artifactUrl and targetUrl and API_ROOT stay in admin_backups.js, beside the requests that use them. The read-reach generator resolves a path builder only inside the file that calls it, so moving them would drop the backup requests from the admin page's reach.

Behaviour is unchanged. All 343 removed lines appear verbatim in the new file. The only new lines are the wrapper, a header comment, blank lines, a section marker and the returned name list.

Lists that name static files

The new file is added beside admin_backups.js in qa/ui-crawl/controls.js (UI sources), tests/test_ses_unknown_occupancy_consumers.py (occupancy-read exemptions, same reason), qa/admin-draft-target-ownership.spec.js (static routes) and tests/js/admin_reference_count.test.js (files scanned for unreferenced functions). qa/ui-read-reach.json is regenerated with node scripts/generate_ui_read_reach.js, and --check passes. In the generated file the admin page's script list gains the model first. The reads, classes and paths are identical. Two /api/admin/backups/policy sites are now labelled (top level) instead of createBackupLibrary, because the extractor treats a function body longer than 80% of its file as the module wrapper.

One existing assertion (tests/js/admin_backup_library.test.js, the "no require or import" check) now ignores the library's single require("./admin_backup_model.js").

Tests

New cases in tests/js/admin_backup_library.test.js check four things: the model loads alone as a browser script and as a module (no library loaded); the library's model keeps every key, and the moved ones are the model script's own functions; in a page the library binds whichever model script the page loaded before it, and base.html loads it first; and the model file keeps the library's source rules. All four failed before the move because the file did not exist (ENOENT).

  • node --test tests/js/admin_backup_library.test.js: 102 pass
  • node --test tests/js/admin_backup_state_ownership.test.js: 17 pass
  • node --test tests/js/admin_reference_count.test.js: 7 pass
  • node scripts/generate_ui_read_reach.js --check: ok
  • python -m unittest on the occupancy, backup-retention, source-shape, shard, identity, dev_check, CI-contract, changelog-fragment and container-contract modules: 365 run, 0 failed, 1 skipped

The browser specs (qa/ui-coverage.spec.js, qa/admin-draft-target-ownership.spec.js) are covered by CI.

Refs #1328

gcs8 added 2 commits November 17, 2026 00:02
Move the pure part of the backup library's model (scrubbing, ids, labels,
grouping, the policy, plan and status wording, the settings payload and the
target field sets) out of admin_backups.js into a new static script,
admin_backup_model.js. The new file works as a browser script
(window.AdminBackupModel) and as a CommonJS module. admin_backups.js takes
the names it uses from it, so the library's exports, its model object and its
behaviour are unchanged. base.html loads the model before the library.

The URL builders artifactUrl and targetUrl and the API root stay in
admin_backups.js beside the requests that use them, so the read-reach
generator still resolves every backup request on the admin page.

The new file is added to the lists of UI sources, occupancy-read exemptions,
admin static routes in the draft-target spec and reference-count files, and
qa/ui-read-reach.json is regenerated.

Refs #1328
@gcs8

gcs8 commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T05:41:02.170905Z 4fbff42 Manual request
🔒 Security Review ✅ Completed 2026-11-17T05:44:15.645998Z 4fbff42 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the internal Refactor, chore, test or CI change with no operator-visible behavior label Nov 17, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 4fbff42a6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4fbff42a6c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@gcs8

gcs8 commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 4fbff42a6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4fbff42a6c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Refactor, chore, test or CI change with no operator-visible behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant