ZDDC/zddc/internal/handler/default-project-mdl.form.yaml
ZDDC e3db2f8473 feat(records): simplest default tracking number + folder-bound originator
Two coupled cleanups so the baked-in defaults reflect the actual
convention instead of leaking one project's choices into every
deployment:

- Drop the project-wide phase/area components from the default
  filename_format, form schemas, and table columns. They must be
  all-on or all-off across a project to keep filenames lexically
  consistent, so the simplest default omits them; operators re-enable
  via the commented-out templates + a .zddc filename_format override.
  Teaching comments (incl. a field_codes: example) now ride along in
  defaults.zddc.yaml, which `show-defaults` dumps verbatim.
- Separate suffix from sequence with a template hyphen
  ({sequence}-{suffix?}); stored suffix is now just the part marker
  (A, 01) with no leading dash.
- New records: key `folder_fields: {field: parent-distance}` binds a
  body field to an ancestor folder name. The default mdl/rsk records
  bind originator to the party folder (distance 1) — the folder is the
  sole source of truth. The server overwrites the body value before
  validation + composition (WriteWithHistory and the rollup create
  path), and the form renderer marks the field read-only and pre-fills
  it. Rollup forms drop originator from required (server derives it
  from the selected party).

Tests: folder-binding overwrite + wrong-originator-filename 422, and a
form-render readOnly/prefill assertion; existing record tests realigned
so the party folder name equals the originator.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 14:31:49 -05:00

126 lines
4.1 KiB
YAML

# Default project-rollup MDL row schema, served by zddc-server when
# no operator-supplied form.yaml exists at <project>/mdl/.
#
# Identical to the per-party MDL schema (default-mdl.form.yaml)
# except for one extra required field: `party`. That field is the
# routing key — the server reads it on POST <project>/mdl/form.html,
# finds the matching <project>/archive/<party>/ folder, and writes
# the row inside its mdl/ subfolder. The `party` value is stripped
# from the YAML on write (folder name IS the identity); on read the
# dispatcher injects it back so the rollup table can show the
# Package column.
#
# To customize: drop your own form.yaml at <project>/mdl/form.yaml.
# Keep the `party` field shape unless you also customize the rollup
# create handler — the server's routing depends on it.
title: Deliverable (project rollup)
description: One deliverable across all parties. The first field (Package) routes the row to the matching archive/<party>/mdl/ folder; the rest mirrors the per-party MDL schema.
schema:
type: object
# originator is omitted from required: the server derives it from
# the selected party folder (folder_fields) after this schema runs.
required: [party, project, discipline, type, sequence, title]
additionalProperties: false
properties:
party:
type: string
title: Package (party folder)
description: Routing key — must match an existing <project>/archive/<party>/ folder. Typical naming = MasterFormat 4-digit code + C|P + sequence digit (e.g. 0330C1).
pattern: "^[A-Za-z0-9][A-Za-z0-9.-]*$"
minLength: 1
originator:
type: string
title: Originator
description: Auto-set from the selected Package (party folder) — the folder is the source of truth for the originator code. Read-only; leave blank.
readOnly: true
# phase: # project-wide; sits between originator and project
# type: string
# title: Phase
# description: Project phase code (e.g. ECI, EPC).
# minLength: 1
project:
type: string
title: Project
description: Project identifier, or your corporate placeholder for non-project deliverables.
minLength: 1
# area: # project-wide; sits between project and discipline
# type: string
# title: Area
# description: Area / budget code (e.g. B02).
# minLength: 1
discipline:
type: string
title: Discipline
description: Engineering or functional group code (EL, ME, CV, PM, ...).
minLength: 1
type:
type: string
title: Document type
description: Document category code within the discipline (SPC, DWG, RPT, ...).
minLength: 1
sequence:
type: string
title: Sequence
description: Zero-padded integer (0001, 0042, 2623). Stored as a string so leading zeros survive YAML.
minLength: 1
suffix:
type: string
title: Suffix
description: Optional structural-part suffix (A, 01, ...). Just the letters/digits — the leading dash is added by the cascade's filename_format.
title:
type: string
title: Deliverable title
minLength: 1
plannedRevision:
type: string
title: Planned revision
plannedDate:
type: string
title: Planned date
format: date
status:
type: string
title: Current status
enum: [DFT, IFR, IFA, IFC, AFC, AB]
owner:
type: string
title: Owner
notes:
type: string
title: Notes
# --- Audit fields (server-managed; read-only).
created_at:
type: string
title: Created
format: date-time
readOnly: true
created_by:
type: string
title: Created by
format: email
readOnly: true
updated_at:
type: string
title: Updated
format: date-time
readOnly: true
updated_by:
type: string
title: Updated by
format: email
readOnly: true
revision:
type: integer
title: Revision
minimum: 1
readOnly: true
previous_sha:
type: string
title: Previous SHA
readOnly: true
ui:
notes:
ui:widget: textarea