|
| 1 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +# (MPL-2.0 is automatic legal fallback until PMPL is formally recognised) |
| 3 | +# |
| 4 | +# _base.ncl — Shared contractile base |
| 5 | +# |
| 6 | +# Provides four named schema fragments imported by every verb runner: |
| 7 | +# |
| 8 | +# pedigree_schema — canonical pedigree block shape |
| 9 | +# status_core_doc — documentation of the shared status trio (String list) |
| 10 | +# probe_schema — target structured probe form (spec only; verb files |
| 11 | +# still use probe | String with TODO comments) |
| 12 | +# run_defaults — default runner behaviour |
| 13 | +# |
| 14 | +# Usage in a verb runner: |
| 15 | +# |
| 16 | +# let base = import "../_base.ncl" in |
| 17 | +# { |
| 18 | +# pedigree = base.pedigree_schema & { |
| 19 | +# contractile_verb = "must", |
| 20 | +# semantics = "invariant", |
| 21 | +# security = { |
| 22 | +# leash = 'Kennel, |
| 23 | +# trust_level = "read-only verification", |
| 24 | +# allow_network = false, |
| 25 | +# allow_filesystem_write = false, |
| 26 | +# allow_subprocess = true, |
| 27 | +# }, |
| 28 | +# metadata = { |
| 29 | +# name = "must-runner", |
| 30 | +# version = "1.0.0", |
| 31 | +# description = "...", |
| 32 | +# paired_xfile = "Mustfile.a2ml", |
| 33 | +# author = "Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>", |
| 34 | +# }, |
| 35 | +# }, |
| 36 | +# schema = { ... }, |
| 37 | +# run = base.run_defaults & { on_any_fail = "exit-nonzero" }, |
| 38 | +# } |
| 39 | +# |
| 40 | +# See: docs/CONTRACTILE-SPEC.adoc §Shared Base |
| 41 | + |
| 42 | +{ |
| 43 | + # ------------------------------------------------------------------------- |
| 44 | + # pedigree_schema |
| 45 | + # |
| 46 | + # The canonical shape of the `pedigree` block required in every verb runner. |
| 47 | + # Verb runners merge this with their verb-specific values using Nickel's `&` |
| 48 | + # (right-priority merge). Override contractile_verb, semantics, security.*, |
| 49 | + # and metadata.* in each verb. |
| 50 | + # ------------------------------------------------------------------------- |
| 51 | + pedigree_schema = { |
| 52 | + schema_version | String | default = "1.0.0", |
| 53 | + contractile_verb | String | default = "UNSET", # MUST override in verb |
| 54 | + semantics | String | default = "UNSET", # MUST override in verb |
| 55 | + security = { |
| 56 | + leash | [| 'Kennel, 'Yard, 'Hunt |] | default = 'Kennel, |
| 57 | + trust_level | String | default = "UNSET", # MUST override in verb |
| 58 | + allow_network | Bool | default = false, |
| 59 | + allow_filesystem_write | Bool | default = false, |
| 60 | + allow_subprocess | Bool | default = true, |
| 61 | + # verb-specific additional security fields go in the verb's merge override: |
| 62 | + # e.g. authorised_probes_only (trust), injection_scope (bust), |
| 63 | + # destructive_mode_requires_flag (dust) |
| 64 | + }, |
| 65 | + metadata = { |
| 66 | + name | String | default = "UNSET", # MUST override in verb |
| 67 | + version | String | default = "1.0.0", |
| 68 | + description | String | default = "UNSET", # MUST override in verb |
| 69 | + paired_xfile | String | default = "UNSET", # MUST override in verb |
| 70 | + author | String | default = "Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>", |
| 71 | + }, |
| 72 | + }, |
| 73 | + |
| 74 | + # ------------------------------------------------------------------------- |
| 75 | + # status_core_doc |
| 76 | + # |
| 77 | + # Documents the minimum shared status values present in every verb's status |
| 78 | + # enum: declared, verified, failing. |
| 79 | + # |
| 80 | + # Nickel does not support structural enum extension, so verb files reproduce |
| 81 | + # their full enum verbatim in `schema`. This field serves as documentation |
| 82 | + # and for tooling that introspects the base. |
| 83 | + # |
| 84 | + # Verbs that extend status_core (i.e. all except must + trust): |
| 85 | + # adjust: + 'partial |
| 86 | + # bust: + 'drilled |
| 87 | + # dust: 'declared, 'proposed, 'approved, 'removed (non-standard) |
| 88 | + # intend: 'declared, 'in_progress, 'done, 'deferred, 'retired |
| 89 | + # lust: 'declared, 'in_progress, 'achieved, 'abandoned |
| 90 | + # |
| 91 | + # See: docs/CONTRACTILE-SPEC.adoc §Per-Verb Extension |
| 92 | + # ------------------------------------------------------------------------- |
| 93 | + status_core_doc = "status_core values: declared | verified | failing — extended per verb", |
| 94 | + |
| 95 | + # ------------------------------------------------------------------------- |
| 96 | + # probe_schema |
| 97 | + # |
| 98 | + # The TARGET structured probe form. See: docs/CONTRACTILE-SPEC.adoc §Probe |
| 99 | + # |
| 100 | + # IMPORTANT: This is a spec-only definition. Existing verb runner files still |
| 101 | + # use `probe | String` with a `# TODO: migrate to probe_schema` comment. |
| 102 | + # This is a breaking change; migration happens when the CLI supports both |
| 103 | + # forms. |
| 104 | + # |
| 105 | + # Adopters writing new xfiles should prefer the structured form: |
| 106 | + # probe = { |
| 107 | + # command = "test -f my-file", |
| 108 | + # timeout_seconds = 60, |
| 109 | + # allowed_exit_codes = [0], |
| 110 | + # permission_class = 'read_only, |
| 111 | + # } |
| 112 | + # ------------------------------------------------------------------------- |
| 113 | + probe_schema = { |
| 114 | + command | String, |
| 115 | + timeout_seconds | Number | default = 300, |
| 116 | + allowed_exit_codes | Array Number | default = [0], |
| 117 | + permission_class |
| 118 | + | [| 'read_only, 'filesystem_write, 'subprocess, 'network |] |
| 119 | + | default = 'read_only, |
| 120 | + }, |
| 121 | + |
| 122 | + # ------------------------------------------------------------------------- |
| 123 | + # run_defaults |
| 124 | + # |
| 125 | + # Default runner behaviour. Verb runners merge this with verb-specific |
| 126 | + # overrides using Nickel's `&` (right-priority merge). |
| 127 | + # |
| 128 | + # Most verbs override on_any_fail: |
| 129 | + # "exit-nonzero" : hard gate (must, trust, bust, adjust-gating) |
| 130 | + # "continue-with-warnings": advisory (dust, adjust) |
| 131 | + # "continue" : never gate (intend, lust) |
| 132 | + # ------------------------------------------------------------------------- |
| 133 | + run_defaults = { |
| 134 | + on_pass = "continue", |
| 135 | + on_any_fail = "exit-nonzero", |
| 136 | + report_format = "a2ml", |
| 137 | + emit_summary = true, |
| 138 | + }, |
| 139 | +} |
0 commit comments