# Example form spec — daily safety check-in.
#
# Drop this file at any path under ZDDC_ROOT where users have write access via
# the .zddc cascade (e.g. /Working/Daily/safety.form.yaml). zddc-server then
# serves:
#   GET  <path>/safety.form.html              empty form
#   POST <path>/safety.form.html              creates <path>/safety/<date>-<email>.yaml
#   GET  <path>/safety/<id>.yaml.html         form pre-filled from <id>.yaml
#   POST <path>/safety/<id>.yaml.html         updates <id>.yaml
#
# Submissions are plain YAML files — readable in any editor, browsable via the
# existing archive tool. v0 round-trip is form-as-truth: comments in submissions
# are not preserved across edits. (File-as-truth mode for hand-edited files
# like .zddc itself is a v1 feature; see plan.)

title: Daily Safety Check-In
description: Brief end-of-shift safety report. Required daily on active sites.

schema:
  type: object
  required: [date, location, hazardsObserved]
  additionalProperties: false
  properties:
    date:
      type: string
      format: date
      title: Date
      description: Date of the shift being reported.
    location:
      type: string
      enum: [Site A, Site B, Site C, Office]
      title: Location
    hazardsObserved:
      type: boolean
      title: Hazards observed?
      description: Check if anything noteworthy happened during this shift.
    hazards:
      type: array
      title: Hazards
      description: List each hazard observed. Leave empty if nothing to report.
      items:
        type: object
        required: [kind, severity]
        additionalProperties: false
        properties:
          kind:
            type: string
            title: Kind
            description: Short label, e.g. "Loose handrail".
            minLength: 1
            maxLength: 80
          severity:
            type: integer
            title: Severity
            description: 1 = minor, 5 = stop-work.
            minimum: 1
            maximum: 5
          notes:
            type: string
            title: Notes
            description: Anything else worth recording.
    additionalNotes:
      type: string
      title: Additional notes

ui:
  date:
    ui:autofocus: true
  location:
    ui:widget: radio
  hazards:
    ui:options:
      addable: true
      removable: true
  additionalNotes:
    ui:widget: textarea
    ui:placeholder: Anything else worth flagging…
