Skip to content

fix(clients): harden config writeback flows - #171

Merged
loocor merged 5 commits into
mainfrom
fix/client-config-writeback
Aug 2, 2026
Merged

fix(clients): harden config writeback flows#171
loocor merged 5 commits into
mainfrom
fix/client-config-writeback

Conversation

@loocor

@loocor loocor commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Normalize Admin discovery parse formats at the DTO boundary.
  • Auto-attach newly created writable clients through the existing eligibility and attach paths.
  • Align backup filenames, API timestamps, display time, and retention ordering with the actual backup creation instant.
  • Publish stamped backups through a non-discoverable staging path with cross-platform same-second replacement semantics.

Motivation

New writable client records required a second manual Attach action even when they already satisfied the existing attach policy. Backup filenames also used UTC while copied file metadata could preserve the previous configuration modification time on macOS, producing conflicting timestamps in the backup UI.

Configuration and migration impact

  • No database, schema, or runtime migration is required.
  • Existing backup files are not renamed or rewritten.
  • New backup filenames use local YYYYMMDDHHMMSS+ZZZZ timestamps.
  • Non-writable and otherwise ineligible clients retain their existing behavior.

Validation

  • bun test src/lib/client-config-sync.test.ts src/lib/admin-discovery.test.ts — 28 passed.
  • bun run lint — 0 errors; existing repository warnings remain.
  • bun run build — passed.
  • RUSTC_WRAPPER= cargo test system::paths::service::tests --lib — 3 passed.
  • RUSTC_WRAPPER= cargo clippy --all-targets --all-features -- -D warnings — passed.
  • Full RUSTC_WRAPPER= cargo test outside the sandbox — 897 passed; one unrelated parallel-state test failed, then passed on exact rerun.
  • Manual UAT confirmed local-offset backup naming and exposed the copied-metadata timestamp mismatch addressed here.
  • Independent read-only review completed with no remaining findings.

Residual risk

  • Existing backup timestamps remain unchanged by design.
  • The full backend suite still has an observed parallel-state flake in durable_commit_survives_projection_failure_without_a_second_catalog_transition; its exact rerun passed.

loocor added 3 commits August 2, 2026 00:33
- Narrow discovered config parse formats to the supported value set.
- Reject invalid resolved candidates before raw-contract fallback.
- Cover invalid format handling at the Admin adapter boundary.
- Report creation from actual SQLite insert ownership, including races.
- Gate initial backup policy and auto-attach on confirmed creation.
- Reuse authoritative config details and the existing attach API.
- Cover eligible, ineligible, sequential, and concurrent paths.
- Stamp staged snapshots with the local creation instant.\n- Keep API display and retention ordering aligned.\n- Preserve cross-platform same-second replacement semantics.
@loocor loocor self-assigned this Aug 2, 2026
@loocor
loocor requested a review from Copilot August 2, 2026 01:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request hardens the client configuration writeback and backup publication flows. The backend now reports whether a settings update actually created a new client record, allowing the frontend to initialize the backup policy and attach only after a real creation. It also aligns backup filenames, modification times, and retention ordering with the actual backup creation instant, while tightening parse-format validation at the Admin discovery DTO boundary.

Changes:

  • Add created: boolean to /api/client/update responses. Concurrent insert handling ensures that at most one request reports created=true, and the frontend receives this signal through its API types.
  • Add attachCreatedClientIfEligible so newly created clients are attached automatically only when they satisfy the existing attach eligibility rules.
  • Generate backup filenames from a creation instant with an explicit timezone offset, stamp backup modification times with that instant, prune by modification time, and publish through staging plus replacement to preserve same-second overwrite behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
board/src/lib/types.ts Extends ClientSettingsUpdateData with the backend created signal.
board/src/lib/client-config-sync.ts Adds the eligibility check and execution path for automatic attach after creation.
board/src/lib/client-config-sync.test.ts Covers eligible created clients, the created=false short circuit, and ineligible clients.
board/src/lib/api.ts Narrows the clientsApi.update response type to ClientSettingsUpdateResp.
board/src/lib/admin-discovery.ts Normalizes config parse formats to a constrained union at the DTO boundary and validates resolved candidate inputs more strictly.
board/src/lib/admin-discovery.test.ts Adds rejection coverage for an invalid config format on a resolved candidate.
board/src/components/client-form-drawer.tsx Uses updateResponse.data?.created in create mode to decide whether to initialize backup policy and attempt automatic attach.
backend/src/system/paths/service.rs Aligns backup naming, modification time, publication, and retention semantics with the creation instant and adds regression coverage.
backend/src/clients/service/state.rs Adds state creation helpers that report created and ensure only one concurrent insert returns created=true.
backend/src/clients/service/settings.rs Propagates the creation signal through the settings update result.
backend/src/api/models/client.rs Adds the created field and schema description to the API DTO.
backend/src/api/handlers/client/handlers.rs Populates created in /api/client/update responses and updates handler assertions.

Comment thread board/src/lib/admin-discovery.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdc4d3637f

ℹ️ 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".

Comment thread backend/src/system/paths/service.rs
Comment thread board/src/components/client-form-drawer.tsx
Comment thread board/src/components/client-form-drawer.tsx
- Clarify that all pull request review output must use English.\n- Separate public GitHub text from Chinese day-to-day collaboration.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 2, 2026

Copy link
Copy Markdown

Deploying mcpmate-site with  Cloudflare Pages  Cloudflare Pages

Latest commit: 07b3a8b
Status: ✅  Deploy successful!
Preview URL: https://c2ca14d1.mcp-umate.pages.dev
Branch Preview URL: https://fix-client-config-writeback.mcp-umate.pages.dev

View logs

- Skip automatic attach when backup policy initialization fails.\n- Report invalid resolved Admin client candidates accurately.
@loocor
loocor merged commit 8013349 into main Aug 2, 2026
13 checks passed
@loocor
loocor deleted the fix/client-config-writeback branch August 2, 2026 03:30
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.

2 participants