Skip to content

Part number variants: optional {variant} token, derived families#45

Open
abbyfluoroethane wants to merge 4 commits into
develfrom
part-variants
Open

Part number variants: optional {variant} token, derived families#45
abbyfluoroethane wants to merge 4 commits into
develfrom
part-variants

Conversation

@abbyfluoroethane

@abbyfluoroethane abbyfluoroethane commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds an optional {variant} placeholder to the part numbering format ({tier_code}{sep}{sequence}{sep}{variant}), with a configurable variant_digits width (default 3) in the project wizard. Formats without {variant} behave byte-identically to today.
  • When the format mints variants, new parts get variant 001; POST /api/parts/{id}/variants creates a draft sibling with the next code, copying attributes and BOM lines (audit-logged). An optional body overrides the copied attributes (omitted fields copy, explicit nulls clear; tier/PN never overridable).
  • Variant families are derived from the PN (same tier+sequence base) — one fact, one home: no migration, no new columns. Variant codes are never reused (soft-deleted rows count), and the tier sequence counter never advances for variants.
  • /parts/{pn} is the canonical detail URL; id URLs 302-redirect to it (PNs containing / or shadowing literal sibling routes stay id-addressed).
  • VARIANT opens the shared part form in variant mode (deep link /parts/{ref}/variant): next code and tier rendered as locked facts, everything else prefilled from the source and editable; submit lands on the new draft's page where the existing BOM ledger handles modifications. Part page also gains a VAR ledger row listing live siblings.

Test plan

  • uv run pytest --no-cov — 601 passed, 1 skipped (numbering round-trips, counter isolation, never-recycle, endpoint override/null/parent semantics, PN-URL resolution + redirects, variant-form rendering, graceful degrade without {variant})
  • Live-server golden path: /parts/RV-F-0001-001 direct 200; /parts/1 → 302 to PN URL; VARIANT → form shows RV-F-0001-002 locked + prefilled name; rename + CREATE VARIANT → draft created with BOM copied; sibling listed in VAR ledger
  • Reverting to a no-variant format hides the UI, bounces the deep link, and restores today's behavior exactly

🤖 Generated with Claude Code

Adds an optional {variant} placeholder to the part numbering format
(default 3-digit code, width configurable in the wizard). New parts mint
variant 001; POST /api/parts/{id}/variants creates a draft sibling with
the next code, copying attributes and BOM. Families are derived from the
PN itself — one fact, one home — so no schema change; variant codes are
never reused and the tier sequence counter never advances for variants.
Part page gains a VARIANT action and a VAR ledger row, both absent when
the format mints no variants.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@abbyfluoroethane abbyfluoroethane requested a review from CST-100 June 12, 2026 05:21
@abbyfluoroethane abbyfluoroethane marked this pull request as draft June 12, 2026 06:00
abbyfluoroethane and others added 3 commits June 11, 2026 23:25
/parts/{pn} is now the canonical detail URL; id URLs 302-redirect to it
(parts whose PN holds a '/' or shadows a literal sibling route stay
id-addressed). VARIANT now opens the shared part form in a third mode —
identity rendered as locked facts (next code, source tier), every other
field prefilled from the source and editable — via the /parts/{ref}/variant
deep link; the variants endpoint accepts an optional override body
(omitted fields copy, explicit nulls clear, identity never overridable).
BOM still copies server-side and is edited on the new draft's page.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Parts numbered before {variant} entered the format (e.g. 001-0001) no
longer fall outside the feature: a base regex (format with the {variant}
segment stripped) places them in their tier+sequence family as variant 1,
so the VARIANT action appears and the first explicit variant mints -002 —
code 001 stays a permanent gap, because the base IS configuration 1.
Without this, enabling {variant} on an existing fleet left every
pre-existing part with no way to mint variants.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The wizard's VARIANT DIGITS select becomes VARIANTS: OFF / 2 / 3 / 4
digits. Choosing a width appends {sep}{variant} to the format template;
OFF strips it — the format string remains the single home of the on/off
fact, and hand-edits to the template sync the select back. No backend
change: enablement was already derived from the format.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@abbyfluoroethane abbyfluoroethane marked this pull request as ready for review June 12, 2026 06:55
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