ZDDC/zddc/internal/handler/default-mdl.form.yaml
ZDDC 662bfbdbf9 refactor(records): converge all record-write paths on WriteWithHistory
The in-dir form create/update (serveFormCreate/serveFormUpdate) wrote
records with plain WriteAtomic + date+email naming — no audit stamping,
no filename composition, no field_codes/folder_fields. So "+ Add row"
from a per-party mdl/rsk table produced un-stamped, mis-named rows that
the tables tool's own PUT-update path (which composes) would then 422
on. Only PUT and the project rollup honored the record machinery.

Now every record-write entry point converges on WriteWithHistory:

- Extract the shared field_defaults + folder_fields + row-assign +
  compose step into recordCreatePrep (history.go); the rollup uses it
  too, replacing its inline copy.
- serveFormCreate: when a records: rule with a filename_format applies
  in the target dir, compose the name + route through WriteWithHistory;
  otherwise keep the generic date+email submission write.
- serveFormUpdate: route through WriteWithHistory unconditionally — it
  stamps/historizes records and plain-writes non-records. Editing a
  tracking-number component in place now 422s (identity is the
  filename; renames are delete+create).
- Drop originator from required: in the per-party mdl/rsk forms and mark
  it readOnly, matching the rollup forms — it's server-derived from the
  party folder, so a create needn't send it.

Docs (AGENTS.md, ARCHITECTURE.md) updated for the converged wire
surface. Tests: in-dir record create composes + stamps audit +
folder-binds originator; in-dir update bumps revision and rejects an
in-place component edit.

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

154 lines
5.9 KiB
YAML

# Default row schema for a Master Deliverables List entry, served by
# zddc-server when no operator-supplied form.yaml exists at
# archive/<party>/mdl/.
#
# Properties cover the default ZDDC tracking-number components
# (zddc.varasys.io/reference.html#tracking-numbers) plus the standard
# MDL metadata (title, planned revision, planned date, status, owner,
# notes). The default ships the five required components + an optional
# per-deliverable suffix; the project-wide phase / area components are
# present only as commented-out templates (see below). The schema is
# intentionally permissive on the components (free-text strings, no
# regex / enum constraints) — projects choose their own conventions,
# and a default that imposed a fixed set would just get in the way.
# Tightening per project is done via .zddc field_codes:, which the
# cascade resolves before the form is rendered.
#
# `originator` is folder-bound: the cascade's folder_fields pins it to
# the party-folder name, so the form renders it read-only and the
# server sets it from the path — the folder is its single source of
# truth.
#
# The six audit fields at the bottom are server-managed: clients must
# render them as read-only and never submit values for them.
# WriteWithHistory strips any client-supplied audit fields before
# schema validation and re-injects the authoritative values.
#
# To customize: drop your own form.yaml into archive/<party>/mdl/
# (the same directory as table.yaml). Tighten constraints with
# `enum:`, `pattern:`, `minLength:`, etc. To add the project-wide
# phase / area components, uncomment them below AND override the
# cascade's filename_format to include them — apply to EVERY
# deliverable in the project, never a subset. Add fields and they'll
# appear in the row-edit form; add a matching column to table.yaml
# to surface the field in the table view too.
title: Deliverable
description: One planned or in-flight deliverable. The first fields are components of this row's tracking number (originator is set from the party folder); the rest are deliverable metadata.
schema:
type: object
# originator is omitted from required: it's folder-bound — the server
# derives it from the party-folder name (folder_fields) and the form
# renders it read-only.
required: [project, discipline, type, sequence, title]
additionalProperties: false
properties:
# --- Tracking-number components (matches the reference doc's
# field definitions, in order). originator / project / discipline
# / type / sequence are the structural minimum that ships by
# default; suffix is an optional per-deliverable part marker. The
# project-wide phase / area components are commented out below —
# uncomment them (and the matching .zddc filename_format) only if
# your project uses them on EVERY deliverable.
originator:
type: string
title: Originator
description: Bound to the party-folder name — the folder is the source of truth for the originator code. Server-set and read-only; you don't edit it here.
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 (e.g. 000000) 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 for Appendix A, 01 for Sheet 1). Just the letters/digits — the leading dash is added by the cascade's filename_format. Use only for parts of the SAME deliverable; separate documents get their own sequence.
# --- Deliverable metadata.
title:
type: string
title: Deliverable title
minLength: 1
plannedRevision:
type: string
title: Planned revision
description: Issue revision label, e.g. A, B, IFR, IFC.
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
description: Email or party name responsible for producing this row.
notes:
type: string
title: Notes
# --- Audit fields (server-managed; clients must not submit
# values). WriteWithHistory strips any client-supplied versions
# before validation and re-injects authoritative values.
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
description: SHA-256 (first 8 hex chars) of the prior revision's bytes.
readOnly: true
ui:
notes:
ui:widget: textarea