Skip to content

feat(hub): edit registered prototype names - #256

Merged
nshki merged 6 commits into
nshki/fix/hub/serialize-session-revocationfrom
nshki/feat/hub/edit-registered-prototype-name
Nov 16, 2026
Merged

nshki merged 6 commits into
nshki/fix/hub/serialize-session-revocationfrom
nshki/feat/hub/edit-registered-prototype-name

Conversation

@nshki

@nshki nshki commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Why

Members can inspect registered prototypes in Hub, but they cannot correct a registered prototype's name. This adds a simple metadata correction path without replacing the prototype or its build history.

What changes

Signed-in members who can see a registered prototype can update its name through the API. Hub trims and validates the name, then writes and reads back the updated detail in one transaction while current session authority and prototype visibility remain locked. Draft registration, description and start-page editing, and a client-side editor remain out of scope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
@nshki
nshki requested an adaptive review from Copilot November 14, 2026 08:26
@nshki
nshki added this pull request to stack #255 November 14, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The visibility-lock guarantee lacks a two-connection PostgreSQL test proving that repository removal or default-branch changes block until an edit commits.

2 open issues
What changed in this PR

Adds an API for signed-in members to rename visible, registered prototypes without replacing their identity or Build history. The client-side editor and draft registration remain out of scope.

Changes:

  • Adds an origin-checked PATCH endpoint with name validation.
  • Keeps session authority, prototype visibility, the update, and detail read-back in one transaction.
  • Adds database tests and updates guides to describe the API and its limits.
File Description
hub/​server/​routes/​index.ts Registers the protected PATCH endpoint.
hub/​server/​routes/​api/​repositories/​prototypes/​show/​patch/​index.ts Validates requests and returns updated details.
hub/​server/​routes/​api/​repositories/​prototypes/​show/​patch/​index.db.test.ts Tests edits, validation, access, rollback, and session concurrency.
hub/​server/​routes/​api/​repositories/​prototypes/​show/​get/​index.db.test.ts Confirms drafts still report editing unavailable.
hub/​server/​routes/​api/​product/​types.ts Adds the metadata-edit dependency contract.
hub/​server/​routes/​api/​product/​create-product-route-dependencies/​index.ts Wires editing and authority checks into one transaction.
hub/​server/​repositories/​prototypes/​update-prototype-metadata/​index.ts Persists the prototype name using Prisma.
hub/​server/​repositories/​prototypes/​lock-editable-prototype/​index.ts Locks the prototype and repository visibility fields.
hub/​server/​repositories/​prototype-index/​find-prototype-detail/​index.ts Allows detail reads within the edit transaction.
hub/​server/​domains/​prototypes/​errors.ts Defines metadata-edit errors.
hub/​server/​domains/​prototypes/​edit-prototype-metadata/​index.ts Validates names and coordinates authorized edits.
hub/​server/​create-app/​index.ts Defers JSON parsing until after the route’s origin check.
hub/​docs/​frontend.md Distinguishes API editing from the unavailable client editor.
hub/​docs/​authentication.md Documents edit locking and authentication contention.
hub/​docs/​architecture.md Describes the endpoint and transaction guarantees.
hub/​AGENTS.md Updates contributor guidance for name-editing support.

Review effort: Balanced (dynamic)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Quadratic-time name trimming can block the API event loop, while exclusive locks on all authentication-provider rows can stall sign-in and session restoration across Hub.

2 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Test NUL and lone-surrogate rejection

hub/​server/​routes/​api/​repositories/​prototypes/​show/​patch/​index.db.test.ts:186

The invalid-edit case never sends NUL or a lone surrogate, so it does not cover the new unsupported-character rejection. A regression could turn these inputs into a database error or save altered text instead of returning 400. Add both inputs here and assert a 400 response with no record changes.

Medium severity Register hidden-branch fixtures to test visibility

hub/​server/​routes/​api/​repositories/​prototypes/​show/​patch/​index.db.test.ts:226

Both hidden-branch fixtures are unregistered, so the draft check rejects them even if lockEditablePrototype stops filtering the default and installation branches. This leaves the new PATCH visibility rule untested. Give these two fixtures a nonblank name and registeredAt so the existing 404 and unchanged-record assertions exercise branch visibility rather than draft rejection.

Low severity Document PATCH rules in the frontend API contract

hub/​docs/​architecture.md:25

The detailed PATCH rules are documented in this architecture overview, while the real-mode API contract in hub/docs/frontend.md:208 still lists only GET endpoints. Move the PATCH validation, visibility, and error rules into that contract and leave a brief summary with a link here, following docs/documentation-conventions.md's rule that overviews summarize and link to the main guide.

2 resolved since last review

Review effort: Max (dynamic)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The documentation describes the mock PATCH endpoint as name-only, but it still requires both name and description, causing name-only requests to return 422 in mock mode.

1 open issue
2 resolved since last review

Review effort: Max (dynamic)

Comment thread hub/docs/frontend.md Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because transaction-cached PostgreSQL activity can cause the concurrency test to time out on stale query data even when revocation is blocked.

No open issues 🎉

1 resolved since last review

Review effort: Max (dynamic)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
@nshki
nshki requested an adaptive review from Copilot November 14, 2026 15:16
@nshki

nshki commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Copilot: Fixed the stale PostgreSQL activity snapshot in 3b76067a. The lock-wait test now refreshes the snapshot before each poll.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human judgment is needed to weigh non-blocking concerns about validation messaging, input-validation test coverage, and transaction-lock ownership.

No open issues 🎉

Review effort: Max (dynamic)

@nshki
nshki marked this pull request as ready for review November 16, 2026 15:34
@nshki
nshki requested a review from a team as a code owner November 16, 2026 15:34
@nshki
nshki merged commit fab00bb into build/hub/new Nov 16, 2026
50 checks passed
@nshki
nshki deleted the nshki/feat/hub/edit-registered-prototype-name branch November 16, 2026 17:48
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.

3 participants